package com.genexususa.eo.bing.data.results;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.BatchError;

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "AdGroupsResult")
public class GxAdGroupsResult extends GxGeneralResult {
    @XmlElement(name = "TrackingId")
    public String specificTrackingId;
    @XmlElement(name = "GxCampaignId")
    public long gxCampaignId;
    @XmlElement(name = "BingCampaignId")
    public long bingCampaignId;
    @XmlElementWrapper(name = "AdGroupResultCollection")
    @XmlElement(name = "AdGroupResult")
    public GxIdResult[] adGroupResults;

    public GxAdGroupsResult() {
        super();
    }

    public GxIdResult[] getAdGroupResults() {
        return adGroupResults;
    }

    public void createAdGroupCollection(int adGroupQuantity) {
        this.adGroupResults = new GxIdResult[adGroupQuantity];
    }

    public void addAdGroupResult(int index, long gxId, long id) {
        this.adGroupResults[index] = new GxIdResult(gxId, id);
    }

    public void addAdGroupResult(int index, long gxId) {
        this.adGroupResults[index] = new GxIdResult(gxId);
    }

    public void setSpecificTrackingId(String trackingId) {
        this.specificTrackingId = trackingId;
    }

    public void setGxCampaignId(long gxCampaignId) {
        this.gxCampaignId = gxCampaignId;
    }

    public void setBingCampaignId(long bingCampaignId) {
        this.bingCampaignId = bingCampaignId;
    }

    public void addBatchError(BatchError error) {
        this.hasError = true;
        this.adGroupResults[error.getIndex()-1].addBatchError(error);
    }
}
